package pk.nak.client.activity;

import java.util.ArrayList;

import pk.nak.adapters.MenuItemAdapter;
import pk.nak.client.R;
import pk.nak.data.EatOut;
import pk.nak.data.EatOutMenuItem;
import pk.nak.enums.ExtraIDs;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

public class EatOutMenuActivity extends Activity {
	private ArrayList<EatOutMenuItem> _items;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    EatOut eo = (EatOut) this.getIntent().getSerializableExtra(ExtraIDs.SELECTED_EATOUT_SERIALIZABLE);
	    if ( eo != null ){
	    	if ( eo.Menu() != null ){
			    this._items = eo.Menu().getItems();	    		
	    	}else{
	    		this._items = new ArrayList<EatOutMenuItem>();
	    		Toast.makeText(this, "No Menu is defined yet", Toast.LENGTH_LONG).show();
	    	}
		    this.setContentView(R.layout.eatoutmenu);
		    this.PopulateMenuItems();
	    }
	    // TODO Auto-generated method stub
	}
	
	private void PopulateMenuItems(){
		MenuItemAdapter miaMenuItems = new MenuItemAdapter(this, R.layout.eatoutmenuitemrow, this._items);
		ListView lv = (ListView) findViewById(R.id.lvMenuItems);
		lv.setAdapter(miaMenuItems);
	}
}
